
//
//  CityView.m
//  PTravel
//
//  Created by dllo on 15/11/25.
//  Copyright © 2015年 李涵. All rights reserved.
//

#import "CityView.h"

@implementation CityView

- (void)dealloc
{
    [_cnname release];
    [_enname release];
    [_choiceImage release];
    [_viewImage release];
    [_eatImage release];
    [_activityImage release];
    [_travelImage release];
    [_likeImage release];
    [_commpanyImage release];
    [_aqImage release];
    [_ideaImage release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView
{

    dispatch_async(dispatch_get_main_queue(), ^{
        [self getData];
    });

    self.bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, BOUNDS.size.width, BOUNDS.size.height)];
    [self addSubview:self.bgImage];
    [_bgImage release];
    
    UIImageView *a = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, BOUNDS.size.width, BOUNDS.size.height)];
    a.backgroundColor = [UIColor colorWithWhite:1.000 alpha:0.500];
    [self.bgImage addSubview:a];
    [a release];
    
    self.cnname = [[UILabel alloc] initWithFrame:CGRectMake(30*WIDTH, 50*HEGIHT, 200*WIDTH, 40*HEGIHT)];
    self.cnname.font = [UIFont systemFontOfSize:24];
    self.cnname.textColor = [UIColor colorWithWhite:0.104 alpha:1.000];
    [a addSubview:self.cnname];
    [_cnname release];
    
    self.enname = [[UILabel alloc] initWithFrame:CGRectMake(self.cnname.frame.origin.x, self.cnname.frame.origin.y+self.cnname.frame.size.height, self.cnname.frame.size.width, 30)];
    self.enname.textColor = [UIColor colorWithWhite:0.104 alpha:1.000];
    [a addSubview:self.enname];
    [_enname release];
    
    
    //城市所在时间
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(BOUNDS.size.width-240, self.cnname.frame.origin.y+self.cnname.frame.size.height+50, 260*WIDTH, 50*HEGIHT)];
    self.timeLabel.textColor = [UIColor colorWithWhite:0.104 alpha:1.000];
    self.timeLabel.font = [UIFont systemFontOfSize:20];
    [a addSubview:self.timeLabel];
    [_timeLabel release];
    
    //精选
    self.choiceImage = [[UIImageView alloc] initWithFrame:CGRectMake(20*WIDTH, BOUNDS.size.height/2-80*HEGIHT, (BOUNDS.size.width-20)/4-30*WIDTH, (BOUNDS.size.width-20)/4-30*HEGIHT)];
    self.choiceImage.backgroundColor = [UIColor cyanColor];
    self.choiceImage.layer.masksToBounds = YES;
    self.choiceImage.layer.cornerRadius = ((BOUNDS.size.width-20)/4-30)/2;
    self.choiceImage.image = [UIImage imageNamed:@"iconfont-jingxuan-2.png"];
    [a addSubview:self.choiceImage];
    [_choiceImage release];
    
    self.choiceLabel = [[UILabel alloc] initWithFrame:CGRectMake(20*WIDTH, BOUNDS.size.height/2-80*HEGIHT+(BOUNDS.size.width-20)/4-30*HEGIHT, (BOUNDS.size.width-20)/4-30*WIDTH, 20*HEGIHT)];
    self.choiceLabel.text = @"精选";
    self.choiceLabel.textAlignment = 1;
    self.choiceLabel.font = [UIFont systemFontOfSize:15];
    [a addSubview:self.choiceLabel];
    [_choiceLabel release];
    
    //景点
    self.viewImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.choiceImage.frame.origin.x+self.choiceImage.frame.size.width+30*WIDTH, self.choiceImage.frame.origin.y, (BOUNDS.size.width-20)/4-30*WIDTH, (BOUNDS.size.width-20)/4-30*HEGIHT)];
    self.viewImage.backgroundColor = [UIColor cyanColor];
    self.viewImage.layer.masksToBounds = YES;
    self.viewImage.layer.cornerRadius = ((BOUNDS.size.width-20)/4-30*WIDTH)/2;
    self.viewImage.image = [UIImage imageNamed:@"iconfont-jingdian-2.png"];
    [a addSubview:self.viewImage];
    [_viewImage release];
    
    self.viewLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.viewImage.frame.origin.x, self.choiceLabel.frame.origin.y, (BOUNDS.size.width-20*WIDTH)/4-30*WIDTH, 20*HEGIHT)];
    self.viewLabel.text = @"景点";
    self.viewLabel.font = [UIFont systemFontOfSize:15];
    self.viewLabel.textAlignment = 1;
    [a addSubview:self.viewLabel];
    [_viewLabel release];
    
    //美食
    self.eatImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.viewImage.frame.origin.x+self.viewImage.frame.size.width+30, self.choiceImage.frame.origin.y, (BOUNDS.size.width-20*WIDTH)/4-30*HEGIHT, (BOUNDS.size.width-20*WIDTH)/4-30)];
    self.eatImage.backgroundColor = [UIColor cyanColor];
    self.eatImage.layer.masksToBounds = YES;
    self.eatImage.layer.cornerRadius = ((BOUNDS.size.width-20*WIDTH)/4-30*HEGIHT)/2;
    self.eatImage.image = [UIImage imageNamed:@"iconfont-meishi.png"];
    [a addSubview:self.eatImage];
    [_eatImage release];
    
    self.eatLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.eatImage.frame.origin.x, self.choiceLabel.frame.origin.y, (BOUNDS.size.width-20*WIDTH)/4-30*HEGIHT, 20)];
    self.eatLabel.font = [UIFont systemFontOfSize:15];
    self.eatLabel.text = @"美食";
    self.eatLabel.textAlignment = 1;
    [a addSubview:self.eatLabel];
    [_eatLabel release];
    
    //购物与活动
    self.activityImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.eatImage.frame.origin.x+self.eatImage.frame.size.width+30*WIDTH, self.choiceImage.frame.origin.y, (BOUNDS.size.width-20*WIDTH)/4-30*HEGIHT, (BOUNDS.size.width-20*WIDTH)/4-30*HEGIHT)];
    self.activityImage.backgroundColor = [UIColor cyanColor];
    self.activityImage.layer.masksToBounds = YES;
    self.activityImage.layer.cornerRadius = ((BOUNDS.size.width-20*WIDTH)/4-30*HEGIHT)/2;
    self.activityImage.image = [UIImage imageNamed:@"iconfont-gouwu.png"];
    [a addSubview:self.activityImage];
    [_activityImage release];
    
    self.activityLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.activityImage.frame.origin.x-10*WIDTH, self.choiceLabel.frame.origin.y, self.choiceLabel.frame.origin.y, 20*HEGIHT)];
    self.activityLabel.font = [UIFont systemFontOfSize:15];
    self.activityLabel.text = @"购物与活动";
    [a addSubview:self.activityLabel];
    [_activityLabel release];
    
    //各种线
    UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, self.activityLabel.frame.origin.y+self.activityLabel.frame.size.height+30*HEGIHT, BOUNDS.size.width, 1)];
    line.backgroundColor = [UIColor blackColor];
    [a addSubview:line];
    [line release];
    
    UIView *vLine = [[UIView alloc] initWithFrame:CGRectMake(BOUNDS.size.width/2, line.frame.origin.y + 14*HEGIHT, 1, 36*HEGIHT)];
    vLine.backgroundColor = [UIColor blackColor];
    [a addSubview:vLine];
    [vLine release];
    
    self.travelImage = [[UIImageView alloc] initWithFrame:CGRectMake(BOUNDS.size.width/10, line.frame.origin.y + 14*HEGIHT, 36*WIDTH, 36*HEGIHT)];
    self.travelImage.image = [UIImage imageNamed:@"iconfont-xingchengxianxing.png"];
    [a addSubview:self.travelImage];
    [_travelImage release];
    
    self.travelLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.travelImage.frame.origin.x+self.travelImage.frame.size.width, self.travelImage.frame.origin.y, 80*WIDTH, 36*HEGIHT)];
    self.travelLabel.text = @"我的行程";
    self.travelLabel.font = [UIFont systemFontOfSize:17];
    [a addSubview:self.travelLabel];
    [_travelLabel release];
    
    UIView *linee = [[UIView alloc] initWithFrame:CGRectMake(10*WIDTH,line.frame.origin.y+70*HEGIHT, BOUNDS.size.width-20*WIDTH, 1)];
    linee.backgroundColor = [UIColor blackColor];
    [a addSubview:linee];
    [linee release];
    
    self.likeImage = [[UIImageView alloc] initWithFrame:CGRectMake(BOUNDS.size.width/10+BOUNDS.size.width/2, line.frame.origin.y + 14*HEGIHT, 36*WIDTH, 36*HEGIHT)];
    self.likeImage.image = [UIImage imageNamed:@"iconfont-shoucang.png"];
    [a addSubview:self.likeImage];
    [_likeImage release];
    
    self.likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.travelImage.frame.origin.x+self.travelImage.frame.size.width+BOUNDS.size.width/2, self.travelImage.frame.origin.y, 80*WIDTH, 36*HEGIHT)];
    self.likeLabel.text = @"我的想去";
    self.likeLabel.font = [UIFont systemFontOfSize:17];
    [a addSubview:self.likeLabel];
    [_likeLabel release];
    
    
    self.commpanyImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.travelImage.frame.origin.x, line.frame.origin.y + 82*HEGIHT, 30*WIDTH, 30*WIDTH)];
    self.commpanyImage.image = [UIImage imageNamed:@"iconfont-hezuohuoban.png"];
    [a addSubview:self.commpanyImage];
    [_commpanyImage release];
    
    self.commpanyLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.commpanyImage.frame.origin.x, self.commpanyImage.frame.origin.y+self.commpanyImage.frame.size.height, 80*WIDTH, 30*HEGIHT)];
    self.commpanyLabel.text = @"结伴";
    self.commpanyLabel.font = [UIFont systemFontOfSize:17];
    [a addSubview:self.commpanyLabel];
    [_commpanyLabel release];
    
    UIView *vLinee = [[UIView alloc] initWithFrame:CGRectMake(BOUNDS.size.width/3, linee.frame.origin.y + 14*HEGIHT, 1, 36*HEGIHT)];
    vLinee.backgroundColor = [UIColor blackColor];
    [a addSubview:vLinee];
    [vLinee release];
    
    self.aqImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.travelImage.frame.origin.x+BOUNDS.size.width/3, line.frame.origin.y + 82*HEGIHT, 30*WIDTH, 30*HEGIHT)];
    self.aqImage.image = [UIImage imageNamed:@"iconfont-icon8.png"];
    [a addSubview:self.aqImage];
    [_aqImage release];
    
    self.aqLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.aqImage.frame.origin.x, self.commpanyImage.frame.origin.y+self.commpanyImage.frame.size.height, 80*WIDTH, 30*HEGIHT)];
    self.aqLabel.text = @"问答";
    self.aqLabel.font = [UIFont systemFontOfSize:17];
    [a addSubview:self.aqLabel];
    [_aqLabel release];
    
    UIView *vLineee = [[UIView alloc] initWithFrame:CGRectMake(BOUNDS.size.width/3*2, linee.frame.origin.y + 14*WIDTH, 1, 36*HEGIHT)];
    vLineee.backgroundColor = [UIColor blackColor];
    [a addSubview:vLineee];
    [vLineee release];
    
    self.ideaImage = [[UIImageView alloc] initWithFrame:CGRectMake(self.travelImage.frame.origin.x+BOUNDS.size.width/3*2, line.frame.origin.y + 74*HEGIHT, 36*WIDTH, 36*HEGIHT)];
    self.ideaImage.image = [UIImage imageNamed:@"iconfont-iconupload.png"];
    [a addSubview:self.ideaImage];
    [_ideaImage release];
    
    self.ideaLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.ideaImage.frame.origin.x, self.commpanyImage.frame.origin.y+self.commpanyImage.frame.size.height, 80*WIDTH, 30*HEGIHT)];
    self.ideaLabel.text = @"锦囊";
    self.ideaLabel.font = [UIFont systemFontOfSize:17];
    [a addSubview:self.ideaLabel];
    [_ideaLabel release];
    
    UIView *lineee = [[UIView alloc] initWithFrame:CGRectMake(0, linee.frame.origin.y+70*HEGIHT, BOUNDS.size.width, 1)];
    lineee.backgroundColor = [UIColor blackColor];
    [a addSubview:lineee];
    [lineee release];

    

}


- (void)getData
{
    [self.cityViewDelegate cityAction];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
